package com.highspeed.bdk.gateway.socket.analyze.message.gui.resolver;

import com.highspeed.bdk.gateway.Util;
import com.highspeed.bdk.gateway.socket.analyze.message.gui.base.MessageResolver;

import java.util.Map;

/**
 * 3.24反馈物理链路统计信息定义
 * typedef struct _onePhyLinkStatics
 * {
 * U32 startPortId; //链路起点Id 16-bit rionet id + 16-bit portId
 * U32 endPortId;//链路终点Id  16-bit rionet id + 16-bit portId
 * PhyPortStatics startStatics;
 * PhyPortStatics endStatics;
 * } OnePhyLinkStatics;
 * typedef struct _phylinkStatics
 * {
 * U32 linkSum;//link的总条数
 * U16 oneLinkDataLen;//每条链路的数据的长度
 * U16 reserved;
 * OnePhyLinkStatics data[0];//可变长，用于顺序存贮每条链路的数据
 * } PhyLinkStaticsFbData;
 */
public class OnePhyLinkStaticsResolver extends MessageResolver {

    @Override
    protected Map doResolveBody(byte[] response) {
        short startRionetId = Util.getShort(response, getOffset());
        offset2();
        short startPortId = Util.getShort(response, getOffset());
        offset2();
        logger.info("链路起点rionetId............." + startRionetId + ", portId.........." + startPortId);

        short endRionetId = Util.getShort(response, getOffset());
        offset2();
        short endPortId = Util.getShort(response, getOffset());
        offset2();
        logger.info("链路起点rionetId............." + endRionetId + ", portId.........." + endPortId);

        long inUniPkts = Util.getLong(response, getOffset());
        offset8();
        logger.info("inUniPkts............." + inUniPkts);

        long inReSyms = Util.getLong(response, getOffset());
        offset8();
        logger.info("inReSyms............." + inReSyms);

        long inUni32Bits = Util.getLong(response, getOffset());
        offset8();
        logger.info("inUni32Bits............." + inUni32Bits);

        long outUniPkts = Util.getLong(response, getOffset());
        offset8();
        logger.info("outUniPkts............." + outUniPkts);

        long outReSyms = Util.getLong(response, getOffset());
        offset8();
        logger.info("outReSyms............." + outReSyms);

        long outUni32Bits = Util.getLong(response, getOffset());
        offset8();
        logger.info("outUni32Bits............." + outUni32Bits);
        return getContainer();
    }
}
